package cn.mall.goods.service.impl;

import cn.mall.base.mapper.BaseMapper;
import cn.mall.base.utils.PageList;
import cn.mall.goods.domain.Type;
import cn.mall.goods.dto.TypeDto;
import cn.mall.goods.mapper.TypeMapper;
import cn.mall.goods.query.TypeQuery;
import cn.mall.goods.service.ITypeService;
import cn.mall.base.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xizhou
 * @since 2024-12-29
 */
@Service
public class TypeServiceImpl extends BaseServiceImpl<Type> implements ITypeService {

    @Autowired
    private TypeMapper typeMapper;

    @Override
    public PageList<Type> pageListV2(TypeQuery query) {
        long total = typeMapper.loadTotal(query);
        if (total > 0){
            List<Type> rows = typeMapper.pageList(query);
            return new PageList<Type>(total, rows);
        }
        return new PageList<>();
    }

    @Override
    public List<TypeDto> loadByTypeV2() {
        List<TypeDto> types = typeMapper.loadByTypeV2();
        return types;
    }

    @Override
    public List<TypeDto> loadByBTypeV2() {
        List<TypeDto> types = typeMapper.loadByBTypeV2();
        return types;
    }
}
